package com.ouyang.servlet;

import com.ouyang.poji.RentPeople;
import com.ouyang.service.RentPeopleServiceImpl;
import com.ouyang.service.RentPeopleService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/rentpeople.do")
public class RentPeopleServlet extends HttpServlet {

    RentPeopleService rentPeopleService = new RentPeopleServiceImpl();


    @Override
    protected void doGet ( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost ( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException {
        String method = req.getParameter("method");
        if(method.equals("list")){
            this.RenotPeopleList(req,resp);
        }
    }


    public void RenotPeopleList(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<RentPeople> list = rentPeopleService.getrentpeople();
        req.setAttribute("list",list);
        req.getRequestDispatcher("/admin/rentpeople.jsp").forward(req,resp);
    }
}
